<%@page import="java.util.Calendar"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="cn.com.xf.utils.DateUtils"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	
<%!
	public String getWeekDay(Date d){
	Calendar cal = Calendar.getInstance();
	cal.setTime(d);
	int index = cal.get(Calendar.DAY_OF_WEEK);
	String[] weeks = {"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
	return weeks[index-1];
}
%>
<%
	List<TblOaDutySchedule> list = (List<TblOaDutySchedule>)request.getAttribute("list");
	DutyForm form = (DutyForm)request.getAttribute("command");
	UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	String siteName = userInfo.getSiteName();
	String siteId = form.getSiteId();
	String deptId = form.getDeptId();
	String dutyTime = DateUtils.formatDate(new Date());
	if(form!=null&&!form.equals("")){
	}
%>
<div class="main">
	<div class="oaTable">
<table class="tableList">
		<thead>
				<tr>
					<td colspan="11" style="width: 100%;">
						<div class="box FormTools">
							<div>
								 <input type="button" class="searchSubmit"
									onclick="javascript:XF.Duty.scheduleListSearch()" value="搜索" />
							</div>
							<div>
								部门： <select id="deptList" class="easyui-combobox" name="deptid"
									style="width: 100px;"></select>
							</div>
							<div>
								所属公司： <select id="siteList" class="easyui-combobox"
									name="siteid" style="width: 100px;"></select>
							</div>
							
							<div class="addDuty" id="addDuty" >
								<a class="a-btn-microsoft btn" id="add" href="javascript:
									XF.Duty.addSchedule('<%=siteId %>','<%=deptId %>')">添加班次信息</a>
							</div>
						</div>
					</td>
				</tr>
			</thead>

	<tbody>
		<tr id="tableHeader">
			<th style="width: 5%">编号</th>
			<th style="width: 10%">部门</th>
			<th style="width: 10%">班次</th>
			<th style="width: 10%">开始时间</th>
			<th style="width: 10%">结束时间</th>
			<th style="width: 10%">录入人</th>
			<th style="width: 10%">操作</th>
		</tr>
		<%
			int i =1;
			if (list != null && list.size() > 0) {
				for (TblOaDutySchedule scheduel: list) {
		%>
						<tr>
							<td><%=i %></td>
							<td><%=scheduel.getDeptName()!=null?scheduel.getDeptName():"" %></td>
							<td><%=scheduel.getClassName()!=null?scheduel.getClassName():"" %></td>
							<td><%=scheduel.getStartTime()!=null?scheduel.getStartTime():"" %></td>
							<td><%=scheduel.getEndTime()!=null?scheduel.getEndTime():"" %></td>
							<td><%=scheduel.getEnterUserName()!=null?scheduel.getEnterUserName():"" %></td>
							<td>
								<div class="innerBtnWrap">
									<a class="a-btn-microsoft btn" href="javascript:XF.Duty.editSchedule('<%=scheduel.getScheduleId() %>',
										'<%=scheduel.getSiteId() %>','<%=scheduel.getDeptId() %>')">修改</a>
									<a class="a-btn-microsoft btn topBtn" href="javascript:XF.Duty.deleteSchedule('<%=scheduel.getScheduleId()+"" %>')">删除</a>
								</div>
							</td>
						</tr>
					<%
				    i++;
				}
			}
		%>
	</tbody>
</table>
</div>
</div>
<script>
$('#siteList').combobox({
	/* url:global.contextPath + '/company/siteList', */
	valueField:'siteid',
	textField:'sitename',
	disabled:true
});

$('#deptList').combobox({
	url:global.contextPath + '/duty/datagridDepts?siteId=' + '<%=siteId%>',
	valueField:'deptId',
	textField:'deptName',
	method:'get',
	disabled:true
});
$('#siteList').combobox('setValue', '<%=form.getSiteId()%>');
$('#siteList').combobox('setText', '<%=siteName%>');
var dept = '<%=deptId%>';
	if(dept!='D999'){
		$('#deptList').combobox('setValue', '<%=deptId%>');
	}else{
		$('#deptList').combobox('setValue', '');
	}
	/* $('#schedule_popwin').window(); */
</script>